﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NUnit.Framework;
using Spring.Context;
using Spring.Context.Support;
using upcdew_20111_group2b.CapaDominio;
using upcdew_20111_group2b.CapaPersistencia;
using upcdew_20111_group2b.CapaNegocio;

namespace upcdew_20111_group2b.CapaPrueba
{
    [TestFixture]
    public class TestAdminAreaComun
    {
        private IApplicationContext Spring;

        [TestFixtureSetUp]
        public void InicializarPruebas()
        {
            //"assembly://assembly/namespace/capaPersistencia.xml",
            Spring = new XmlApplicationContext(
                "assembly://upcdew-20111-group2b/upcdew_20111_group2b/CapaPersistencia.xml",
                "assembly://upcdew-20111-group2b/upcdew_20111_group2b/CapaNegocio.xml"
                );
        }

        [Test]
        public void TestRealizarReserva()
        {
            //ReservaService reservaService = new ReservaService();
            AdminAreaComun adminareacomun = (AdminAreaComun)Spring.GetObject("adminAreaComun");            
            Assert.NotNull(adminareacomun);
            Reserva reserva = null;
            Assert.DoesNotThrow(delegate {
                reserva = adminareacomun.CrearReserva("2", "40459127", "A00001", DateTime.Now, 15, "Esta reservado para una fiesta infantil");
            });
            Assert.NotNull(reserva);
            Assert.Greater(reserva.CodReserva, "");
        }

        [Test]
        public void TestListarArea_Comun() 
        { 
            ICollection<Area_Comun> area_comun = null;
            AdminAreaComun adminareacomun = (AdminAreaComun)Spring.GetObject("adminAreaComun");
            Assert.DoesNotThrow(delegate { area_comun = adminareacomun.ListarArea_Comun("Habilitado"); });
            Assert.IsNotNull(area_comun);
            Assert.Greater(area_comun.Count(), 0); 
        }    
    }
}